home *** CD-ROM | disk | FTP | other *** search
/ Clickx 115 / Clickx 115.iso / software / tools / windows / tails-i386-0.16.iso / live / filesystem.squashfs / usr / include / scribus-ng / filewatcher.h < prev    next >
Encoding:
C/C++ Source or Header  |  2009-01-15  |  1.9 KB  |  89 lines

  1. /*
  2. For general Scribus (>=1.3.2) copyright and licensing information please refer
  3. to the COPYING file provided with the program. Following this notice may exist
  4. a copyright and/or license notice that predates the release of Scribus 1.3.2
  5. for which a new license (GPL+exception) is in place.
  6. */
  7. #ifndef FILEWATCHER_H
  8. #define FILEWATCHER_H
  9.  
  10. #include <QDateTime>
  11. #include <QFileInfo>
  12. #include <QList>
  13. #include <QMap>
  14. #include <QObject>
  15. #include <QTimer>
  16.  
  17. #include "scribusapi.h"
  18.  
  19. class SCRIBUS_API FileWatcher : public QObject
  20. {
  21.     Q_OBJECT
  22.  
  23. public:
  24.     FileWatcher(QObject* parent);
  25.     ~FileWatcher();
  26.     bool isActive();
  27.     // Get if file check loop is running
  28.     void isFileCheckRunning();
  29.     // Set the timer length in milliseconds
  30.     void setTimeOut(const int newTimeOut, const bool restartTimer=false);
  31.     // Get the timer length
  32.     int timeOut() const;
  33.     QList<QString> files();
  34.     
  35. public slots:
  36.     //Add a file to the watch list for monitoring
  37.     void addFile(QString fileName);
  38.     //Remove a file from the watch list
  39.     void removeFile(QString fileName);
  40.     //Add a directory to the watch list for monitoring
  41.     void addDir(QString fileName);
  42.     //Remove a directory from the watch list
  43.     void removeDir(QString fileName);
  44.     //Start the watcher's timer for file monitoring
  45.     void start();
  46.     //Stop the watcher's timer
  47.     void stop();
  48.     //Force a scan of the watched item list
  49.     void forceScan();
  50.  
  51. private:
  52.     struct fileMod
  53.     {
  54.         QFileInfo info;
  55.         QDateTime timeInfo;
  56.         int pendingCount;
  57.         bool pending;
  58.         int refCount;
  59.     };
  60.  
  61.     typedef enum
  62.     {
  63.         AddRemoveBlocked  = 1,
  64.         FileCheckRunning  = 2,
  65.         StopRequested = 4,
  66.         TimerStopped  = 8,
  67.         Dying = 16,
  68.         FileCheckMustStop = 20 //StopRequested + Dying
  69.     } StateFlags;
  70.  
  71.     QMap<QString, fileMod> watchedFiles;
  72.     QTimer* watchTimer;
  73.     int  m_stateFlags;
  74.     int  m_timeOut; // milliseconds
  75.  
  76. private slots:
  77.     void checkFiles();
  78.  
  79. signals:
  80.     void fileChanged(QString);
  81.     void fileDeleted(QString);
  82.     void dirChanged(QString);
  83.     void dirDeleted(QString);
  84.     void statePending(QString);
  85.  
  86. };
  87.  
  88. #endif
  89.